<template>
  <el-form>
    <el-form-item label="用户名">
      <el-input v-model.trim="user.name" readonly />
    </el-form-item>
    <el-form-item label="真实姓名">
      <el-input v-model.trim="realName" readonly />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="logout">关闭</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { updateData } from '@/api/sys/user/user'
import {mapGetters} from 'vuex'

export default {
  props: ['user'],
  methods: {
    async logout() {
      this.$router.back()
      // await this.$store.dispatch('user/login')
      // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
    },

    async submit() {
      updateData(this.user).then(() => {
        this.$notify({
          title: '成功',
          message: '用户资料保存成功！！',
          type: 'success',
          duration: 2000
        })

        this.logout()
      })
    }
  },
  computed:{
    ...mapGetters(["realName"])
  }
}
</script>
